package com.yugao.fintech.vctgone.gateway.config;

import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.properties.SwaggerUiConfigParameters;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * SpringDoc 分组设置
 */
@Component
@RequiredArgsConstructor
@EnableConfigurationProperties(SpringDocConfigProperties.class)
public class SpringDocConfiguration {

    private final SwaggerUiConfigParameters swaggerUiConfigParameters;
    private final SpringDocConfigProperties configProperties;

    @PostConstruct
    public void init() {
        if (configProperties.getServers() != null) {
            for (String value : configProperties.getServers().values()) {
                swaggerUiConfigParameters.addGroup(value);
            }
        }
    }
}